﻿using LNet;
using OestsCommon.Model;
using OestsDataBase;
using OestsServer.Net;
using System.Collections.Generic;

/// <summary>
/// 静态请求名称空间，请求后移除对该类型的监听
/// </summary>
namespace OestsServer.Handlers.UnityHandlers
{
    /// <summary>
    /// 处理请求表数据
    /// </summary>
    public class AreaTableHandler : HandlerBase<UnityClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.AreaTable;
            }
        }

        public override void Execute(UnityClientChannel client, Request packet)
        {
            //读取数据库
            List<AreaModel> list = AreaDAL.GetData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }


    /// <summary>
    /// 处理请求表数据
    /// </summary>
    //public class MajorTableHandler : HandlerBase<UnityClientChannel>
    //{
    //    public override PacketKey PKey
    //    {
    //        get
    //        {
    //            return PacketKey.MajorTable;
    //        }
    //    }

    //    public override void Execute(UnityClientChannel client, Request packet)
    //    {
    //        //读取数据库
    //        List<MajorModel> list = MajorDAL.GetData();
    //        ResponsePacket.DataObject = list;
    //        client.Send(ResponsePacket);
    //    }
    //}


    /// <summary>
    /// 处理请求表数据
    /// </summary>
    public class PostTableHandler : HandlerBase<UnityClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.PostTable;
            }
        }
        public override void Execute(UnityClientChannel client, Request packet)
        {
            //读取数据库
            // List<PostModel> list = ProjectPostDAL.GetPostsInProject((int)client.ProjectType);
            List<PostModel> list = PostDAL.GetAllPost();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }

    public class ProjectPostTableHandler : HandlerBase<UnityClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.ProjectPostTable;
            }
        }
        public override void Execute(UnityClientChannel client, Request packet)
        {
            //读取数据库
            List<ProjectPostModel> list = ProjectPostDAL.GetData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }
    /// <summary>
    /// 处理请求表数据
    /// </summary>
    public class PostTaskTableHandler : HandlerBase<UnityClientChannel>
    {
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.PostTaskTable;
            }
        }

        public override void Execute(UnityClientChannel client, Request packet)
        {
            //读取数据库
            List<PostTaskModel> list = PostTaskDAL.GetData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }

    public class TaskTableHandler : HandlerBase<UnityClientChannel>
    {
        public override PacketKey PKey => PacketKey.TaskTable;

        public override void Execute(UnityClientChannel client, Request resquestPacket)
        {
            int projectID = int.Parse(resquestPacket.DataStr);

            List<TaskModel> list = TaskDAL.GetTasksByProject(projectID);
            ResponsePacket.DataObject = list;

            client.Send(ResponsePacket);
        }
    }

    public class StudentTableHandler : HandlerBase<UnityClientChannel>
    {
        public override PacketKey PKey => PacketKey.StudentTable;

        public override void Execute(UnityClientChannel client, Request resquestPacket)
        {
            //读取数据库
            List<User> list = UserDAL.GetStudentData();
            ResponsePacket.DataObject = list;
            client.Send(ResponsePacket);
        }
    }
}
